#!/usr/bin/perl
use strict;
use Data::Dumper;
use BigIP::F5;

my $settings = {'username' 	=> 'username',
		'password'	=> 'password',
		'server'	=> 'bigip-f5.domain.com',
		'port'		=> '443',
		'protocol'	=> 'https'
		};

# Turns on debugging, and sets the prefix to "# DEBUG >>", if you just setDebug(1), then the default prefix will be ">>"
BigIP::F5->setDebug(1, "# DEBUG >>");


# Initializes the connection to $settings{'server'} with the settings above
my $connection = BigIP::F5->new($settings);

# Check if the connection failed. If so, set debugging to 1 for more details
die ("Unable to connect to " . $settings{'server'} . "\nIt said: " . $connection->fault) if (!$connection);

# Get all partitions
my @partitionList = BigIP::F5->list_partitions();

# Change the active partition, it will default to "Common"
# NOTE: Think of this as a session setting, meaning if you set the active partition to "Production" 
# and run a script, then run the script again later without setting the partition to "Production", the
# F5 will default to the last Partition that was set by the logged in user, so it will still be Production
BigIP::F5->set_active_partition($partitionList[0]);

# Display the current partition, which in this script is the first
# value of the list of pulled partitions above. (@partitionList)
sprintf("Current Partition: %s\n", BigIP::F5->get_active_partition());

# Get a list of pools in the current partition
my @poolList = BigIP::F5->list_pools();

# Get a list of members in the first pool in the above array
my @memberList = BigIP::F5->list_pool_members($poolList[0])

# Lets enable the pool monitoring state
BigIP::F5->set_pool_member_state(	# Below is the partition in which to disable the member
				$partitionList[0],	
				# Below is the member (format is IP:Port EG: 1.2.3.4:80)
				$memberList[0]->{'address'}.":".$memberList[0]->{'port'}, 
				# Below is the status, youc an do Boolean, enabled/disabled or even STATE_ENABLED/STATE_DISABLED
				1
				);
